﻿#include "SpeedWidget.h"
#include "ui_SpeedWidget.h"

SpeedWidget::SpeedWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SpeedWidget)
{
    ui->setupUi(this);
}

SpeedWidget::~SpeedWidget()
{
    delete ui;
}

void SpeedWidget::setSpeedValue(int value)
{
    _iNum = value;
    ui->label_speed->setText(QString::number(value));
}

void SpeedWidget::setMaxValue(int maxValue)
{
    ui->label_speed->setFixedHeight(_iNum * (320-65)/ maxValue);
}

void SpeedWidget::setSpeedStatus(QString status)
{
    if (status == "stop")
    {
        ui->label_speed->setObjectName("label_stop");
    }
    else if (status == "slow")
    {
        ui->label_speed->setObjectName("label_slow");
    } else {
        ui->label_speed->setObjectName("label_normal");
    }
}

void SpeedWidget::setSpeedName(QString strName)
{
    ui->label_name->setText(strName);
}
